{extend name="admin/public/base" /}

{block name="content"}
<!-- Content Header (Page header) -->
<section class="content-header">
  <h1>
    用户列表
    <small></small>
  </h1>
  <ol class="breadcrumb">
    <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
    <li><a href="#">用户</a></li>
    <li class="active">用户列表</li>
  </ol>
</section>

<!-- Main content -->
<section class="content">

    <div class="box box-solid">
        <div class="box-header with-border">
            <a href="{:Url('admin/user/create')}" class="btn btn-default btn-flat"><i class="fa fa-plus-square"></i> 创建用户 </a>
            <div class="pull-right">
                <form method="get" class="form-inline">
                    <div class="input-group">
                      <input type="text" name="keywords" value="{$search.keywords|default=""}" class="form-control" placeholder="Search ...">
                      <span class="input-group-btn">
                        <button type="submit" class="btn btn-default btn-flat">搜索</button>
                      </span>
                    </div>
                </form>
            </div>
        </div>

        <div class="box-body">
            <div class="table-responsive">
                <table class="table table-hover">
                    <thead>
                        <tr>
                            <th>#UID</th>
                            <th>用户名</th>
                            <th>邮箱</th>
                            <th>手机</th>
                            <th>用户组</th>
                            <th>创建时间</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                    {volist name="data" id="vo"}
                        <tr>
                            <td>{$vo.uid}</td>
                            <td>{$vo.username}</td>
                            <td>{$vo.email}</td>
                            <td>{$vo.phone}</td>
                            <td>{$vo.group_name}</td>
                            <td>{$vo.create_at}</td>
                            <td>
                                <div class="btn-group">
                                    <a href="{:Url('admin/user/edit',['uid'=>$vo.uid])}" class="btn btn-default btn-xs"><i class="fa fa-edit"></i></a>
                                    <a onClick="deleteOne({$vo.uid})" class="btn btn-default btn-xs"><i class="fa fa-trash-o"></i></a>
                                </div>
                            </td>
                        </tr>
                    {/volist}
                    </tbody>
                </table>
            </div>

        </div>
        <div class="box-footer">
            <div class="row">
                <div class="col-sm-6">

                </div>
                
                <div class="col-sm-6">
                    <div class="pull-right">
                        {$data->render()}
                    </div>
                </div>
            </div>
        </div>
    </div>

</section>
<!-- /.content -->
{/block}

{block name="js"}
<script>
    function deleteOne(uid){
            swal({
                title: "确定删除这条信息吗?",
                text: "",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                closeOnConfirm: false,
                closeOnCancel: false },
            function (isConfirm) {
                if (isConfirm) {
                    $.ajax({
                        url:"{:Url('admin/user/remove')}",
                        data:{'uid':uid},
                        type:'post',
                        dataType:'json',
                        success: function(xhr){
                            if (xhr.code == 200) {
                                swal(xhr.msg, "", "success");
                            } else {
                                swal(xhr.msg, "", "error");
                            }
                        }
                    })
                } else {
                    swal("取消操作", "", "error");
                }
            });
    }
</script>
{/block}
